
<p><b>syntax:</b> <i>proxy_pass URL</i>
</p><p><b>default:</b> <i>no</i>
</p><p><b>context:</b> <i>location, if in location</i>
</p><p>This directive sets the port or socket, on which listens to the proxied server, and the URI, to which will be reflected location.
</p><p>Port can be indicated in the form of the name of hostname or address and port, for example,
</p><p></p>
<pre class="code"><span class="kw21">proxy_pass</span> <span class="kw3">http</span>://localhost:<span class="nu0">8000</span>/uri/;</pre>
<p>and socket -- in the form of unix of socket:
</p><p></p>
<pre class="code"><span class="kw21">proxy_pass</span> <span class="kw3">http</span>://unix:/path/to/backend.socket:/uri/;</pre>
<p>Path is indicated after the word <code>unix</code> and is concluded between two colons.
</p><p>With the transfer of request to server part URI, which corresponds to location, is substituted to URI, indicated in directive proxy_pass.
</p><p>But there are two exceptions to this rule, when it is not possible to determine that replaced location:
</p>
<ul><li> if the location is assigned by regular expression;
</li><li> if inside proxied location with the help of directive rewrite changes URI and with this configuration will be precisely processed request (break):
</li></ul>
<p></p>
<pre class="code"><span class="kw3">location</span>  /name/ <span class="br0">&#123;</span>
  <span class="kw22">rewrite</span>      /name/<span class="br0">&#40;</span><span class="br0">&#91;</span>^/<span class="br0">&#93;</span> +<span class="br0">&#41;</span>  /users?name=$<span class="nu0">1</span>  <span class="kw22">break</span>;
  <span class="kw21">proxy_pass</span>   <span class="kw3">http</span>://<span class="nu0">127.0</span><span class="nu0">.0</span><span class="nu0">.1</span>;
<span class="br0">&#125;</span></pre>
<p>For these cases of URI it is transferred without the mapping.
</p><p>Furthermore, it is possible to indicate so that URI demand it would be transferred in the same form, as it sent client, but not v in the processed form.
</p><p>During the working:
</p>
<ul><li> two or by more slashes are converted into one slash: "//" -- "/";
</li><li> references to the current directory are removed: "/./" -- "/";
</li><li> references to the previous catalog are removed: "/dir /../" -- "/".
</li></ul>
<p>If on server it is necessary to transmit URI in the unprocessed form, then for this in directive proxy_pass it is necessary to indicate URL server without URI:
</p><p></p>
<pre class="code"><span class="kw3">location</span>  /some/path/ <span class="br0">&#123;</span>
  <span class="kw21">proxy_pass</span>   <span class="kw3">http</span>://<span class="nu0">127.0</span><span class="nu0">.0</span><span class="nu0">.1</span>;
<span class="br0">&#125;</span></pre>
<p>A special case is using variables in the proxy_pass statement: The requested URL is not used and you are fully responsible to construct the target URL yourself.
</p><p>This means, the following is not what you want for rewriting into a zope virtual host monster, as it will proxy always to the same URL (within one server specification):
</p>
<pre class="code"><span class="kw3">location</span> / <span class="br0">&#123;</span>
  <span class="kw21">proxy_pass</span>   <span class="kw3">http</span>://<span class="nu0">127.0</span><span class="nu0">.0</span><span class="nu0">.1</span>:<span class="nu0">8080</span>/VirtualHostBase/https/<span class="re0">$server_name</span>:<span class="nu0">443</span>/some/path/VirtualHostRoot;
<span class="br0">&#125;</span></pre>
<p>Instead use a combination of rewrite and proxy_pass:
</p>
<pre class="code"><span class="kw3">location</span> / <span class="br0">&#123;</span>
  <span class="kw22">rewrite</span> ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ /VirtualHostBase/https/<span class="re0">$server_name</span>:<span class="nu0">443</span>/some/path/VirtualHostRoot/$<span class="nu0">1</span> <span class="kw22">break</span>;
  <span class="kw21">proxy_pass</span>   <span class="kw3">http</span>://<span class="nu0">127.0</span><span class="nu0">.0</span><span class="nu0">.1</span>:<span class="nu0">8080</span>;
<span class="br0">&#125;</span></pre>
<p>In this case URL sanitizing is done already as part of the rewriting process, i.e. a trailing slash with the proxy_pass statement has no further effect.
</p>
<br><i>Module: NginxHttpProxyModule</i>